package com.kuang.thread.state;

public class TestPriority {

    public static void main(String[] args) {
        //主线程默认优先级
        System.out.println(Thread.currentThread().getName() + "====>" + Thread.currentThread().getPriority());

        myPriority myPriority = new myPriority();

        Thread t1 = new Thread(myPriority,"1");
        Thread t2 = new Thread(myPriority,"2");
        Thread t3 = new Thread(myPriority,"3");
        Thread t4 = new Thread(myPriority,"4");

        //先设置优先级再启动最大为10
        t1.start();

        t2.setPriority(1);
        t2.start();

        t3.setPriority(5);
        t3.start();

        t4.setPriority(10);
        t4.start();

    }
}

class myPriority implements Runnable {

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + "====>" + Thread.currentThread().getPriority());
    }
}